package com.dtagri.fjwlw.fragment;

import android.os.Bundle;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import butterknife.ButterKnife;
import butterknife.InjectView;

import com.dtagri.fjwlw.R;
import com.dtagri.fjwlw.base.BaseFragment;
import com.dtagri.fjwlw.util.StringUtils;
import com.dtagri.fjwlw.util.TToast;

/**
 * 反馈
 * 
 * @author wxjn
 * 
 */
public class FeedBackFragment extends BaseFragment {
	@InjectView(R.id.et_feedback)
	EditText mEtContent;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		super.onCreateView(inflater, container, savedInstanceState);
		View view = inflater.inflate(R.layout.fragment_feedback, container,
				false);
		ButterKnife.inject(this, view);
		return view;
	}

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setHasOptionsMenu(true);
	}

	@Override
	public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
		inflater.inflate(R.menu.submit_menu, menu);
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		switch (item.getItemId()) {
		case R.id.public_menu_send:
			String data = mEtContent.getText().toString();
			if (StringUtils.isEmpty(data)) {
				TToast.showToast("你忘记写建议咯");
			} else {
				new Handler().postDelayed(new Runnable() {

					@Override
					public void run() {
						TToast.showToast("已收到你的建议，谢谢");
						getActivity().finish();
					}
				}, 1000);
			}
			break;
		}
		return true;
	}
}
